#pragma once

#include "Vector.h"
#include <vector>

struct MassPoint
{
	Vector* ptrPos;
	Vector  velocity;
	Vector  F;
	bool	bFixed;
};


class Rope
{
public:
	Rope() : mMass(0.0f), mTotalMass(0.0f), ks(100.0f), kd(0.1f) {}
	~Rope() {}

	void init(float mass, int points, Vector p0, Vector p1, bool bPos0Fixed, bool bPos1Fixed);

	void simulate(float dt);
	void SpringForce(MassPoint& mp0, MassPoint& mp1, Vector* f);

	

	void* getDataPtr() { return (void*)posData; }

	MassPoint&	point(int i);

	void addForce(Vector f);

	Vector getPointPos(int i);

	unsigned int	numPoints();

private:
	std::vector<MassPoint> mPoints;
	Vector posData[10];
	
	float	ks;
	float	kd;
	float	Lr;
	
	Vector externalForce;

	float	mMass;
	float	mTotalMass;

};